Repository navigation
Conversation
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2132 +/- ##
==========================================
- Coverage 95.16% 90.68% -4.48%
==========================================
Files 227 227
Lines 22508 22657 +149
==========================================
- Hits 21419 20547 -872
- Misses 1089 2110 +1021
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| def benzene_charged_system(self, benzene_modifications): | ||
| return ChemicalSystem({"ligand": benzene_modifications["benzene"]}, name="charged") | ||
|
|
||
| @pytest.fixture |
There was a problem hiding this comment.
Would it make sense to also add a test where the first smc is charged and the second does not have charges? How would we want to handle such a case?
There was a problem hiding this comment.
Added a test with a system with a mix of charged and uncharged SMCs, this will raise an error on the first one that fails validation. Do you think it would be better however to list all of the SMCs which fail to avoid playing wack-a-mole?
There was a problem hiding this comment.
Changed to flag all components in the ChemicalSystem which fail validation in one error message to hopefully make the experience better!
|
|
||
| for smc in smcs: | ||
| offmol = smc.to_openff() | ||
| if offmol.partial_charges is not None and np.any(offmol.partial_charges): |
There was a problem hiding this comment.
Would we want to support a case where the user supplies partial charges will all zeros?
There was a problem hiding this comment.
+1 - given we have our own benchmark case where we want to do this, we probably should support it
There was a problem hiding this comment.
Yes good idea. Currently, this only works as a Library charge would we want to keep that as a source of protection to make sure users know what they are doing or allow it as charges on the molecule as well?
There was a problem hiding this comment.
That's a good point - I think if it's easily allowed by LibraryCharge then it might be better to keep the check in. There's too many ways someone could accidentally add partial charges.
There was a problem hiding this comment.
Supporting this as a library charge only.
IAlibay
left a comment
There was a problem hiding this comment.
I think this matches what we discussed yesterday - as you mentioned, we should be able to drop the partial charge assignment calls in Protocols with this.
|
|
||
| for smc in smcs: | ||
| offmol = smc.to_openff() | ||
| if offmol.partial_charges is not None and np.any(offmol.partial_charges): |
There was a problem hiding this comment.
+1 - given we have our own benchmark case where we want to do this, we probably should support it
# Conflicts: # src/openfe/tests/protocols/test_openmmutils.py
|
pre-commit.ci autofix |
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
|
🚨 API breaking changes detected! 🚨 Griffe output |
|
pre-commit.ci autofix |
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
|
|
||
| @pytest.mark.parametrize("num", [i for i in range(1, 30)]) | ||
| def test_plot_2D_rmsd(num): | ||
| def test_plot_2D_rmsd(): |
There was a problem hiding this comment.
Sneaking this in can remove if wanted, though, locally this goes from 8s to 650ms while testing more aspects of the output.
There was a problem hiding this comment.
Please move it to a separate PR.
|
pre-commit.ci autofix |
| @@ -27,7 +27,7 @@ def test_get_molecule_sdf(): | |||
|
|
|||
|
|
|||
| def test_get_molecule_mol2(): | |||
There was a problem hiding this comment.
Should we allow loading from mol2? If we go via rdkit -> SMC we silently drop the charges which the users might have intended to use?
There was a problem hiding this comment.
For now yes, we should retain mol2 as an option - this is because it's something we used to offer and we shouldn't break the API over it.
There was a problem hiding this comment.
If we're worried about dropping charges, then the best option for now would be to validate & warn at SMC creation.
There was a problem hiding this comment.
Yeah I think we need to either keep them or warn as they also silently get replaced with am1bcc currently, gufe issue OpenFreeEnergy/gufe#828
There was a problem hiding this comment.
Are we moving these to mol2 because we want to use them elsewhere?
There was a problem hiding this comment.
I have changed them over to SDF as the charges are getting dropped when reading from mol2, triggering the new validation error in tests, the other option is to update gufe to pull these charges when building from rdkit?
|
|
||
| @pytest.mark.parametrize("num", [i for i in range(1, 30)]) | ||
| def test_plot_2D_rmsd(num): | ||
| def test_plot_2D_rmsd(): |
There was a problem hiding this comment.
Please move it to a separate PR.
|
|
||
| # We count library and nagl charges as deterministic | ||
| # While users could use a deterministic charge method with increments we don't currently support this | ||
| if not labels["LibraryCharges"] and "NAGLCharges" not in labels: |
There was a problem hiding this comment.
Is LibraryCharges always guaranteed as a key or could it KeyError?
There was a problem hiding this comment.
Good catch it could be missing, added support for it and a test.
| settings = self._get_settings() | ||
|
|
||
| # Assign partial charges now to avoid any discrepancies later | ||
| self._assign_partial_charges(settings["charge_settings"], small_mols) |
There was a problem hiding this comment.
I've been thinking more about this one - we're silently removing this, but won't users get caught out if they do use a deterministic charge method in the partial charge settings, e.g. NAGL?
There was a problem hiding this comment.
Yeah that would be the downside, users would have to either use a ff with a NAGL handler or pre-charge them. If we keep support for NAGL and espaloma charge methods at runtime only that could work with the default setting being forcefield. It could be confusing if users have to define the forcefield to use in two places 1) the charges setting object and 2) small molecule force field, and then what happens if these are different?
Ideally I would love to keep this as simple as possible for users, we already encourage charging before running so moving to openfe will do no runtime charge generation doesn't feel like too much of a change?
| def test_dry_run_charge_backends( | ||
| CN_molecule, tmp_path, method, backend, ref_key, protocol_dry_settings, am1bcc_ref_charges | ||
| ): | ||
| def test_dry_run_missing_charges(CN_molecule, protocol_dry_settings): |
There was a problem hiding this comment.
It would be good to have a dry run where we use nagl charges
There was a problem hiding this comment.
This would also raise the error, or do you mean with a forcefield with a NAGL handler?
There was a problem hiding this comment.
added back the tests with nagl and espaloma.
| @@ -27,7 +27,7 @@ def test_get_molecule_sdf(): | |||
|
|
|||
|
|
|||
| def test_get_molecule_mol2(): | |||
There was a problem hiding this comment.
For now yes, we should retain mol2 as an option - this is because it's something we used to offer and we shouldn't break the API over it.
| @@ -27,7 +27,7 @@ def test_get_molecule_sdf(): | |||
|
|
|||
|
|
|||
| def test_get_molecule_mol2(): | |||
There was a problem hiding this comment.
If we're worried about dropping charges, then the best option for now would be to validate & warn at SMC creation.
|
Notes from todays power hour:
This should mean that setting openff-2.3.0 as the force field will work and applyNAGL/AshGC charges by default to an uncharged ligand and that using an older ff such as openff-2.2.0 with an am1bcc handler should raise a validation error due to the use of a non-deterministic charge method. Look for other edge cases and report back. We will probably need a blog post alongside this showing why we made this change (examples of poor SepTop results) and what it means going forward. Also expand the partial charge cookbooks to show how to set different charges based on the new settings. |
# Conflicts: # src/openfe/protocols/openmm_md/plain_md_methods.py # src/openfe/tests/conftest.py # src/openfe/tests/protocols/openmm_rfe/test_hybrid_top_protocol.py
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
IAlibay
left a comment
There was a problem hiding this comment.
first batch of review comments - didn't get around to reviewing the one file, will do so tomorrow
| mol = Chem.MolFromMol2File(fn, removeHs=False) | ||
| files[f] = SmallMoleculeComponent(mol, name=f) | ||
| fn = str(d / (f + ".sdf")) | ||
| # go via openff to make sure the partial charges are pulled |
There was a problem hiding this comment.
I don't understand this comment - are we going via OpenFF?
There was a problem hiding this comment.
Good catch, removed the comment.
This was left over from trying different ways to load the charges from mol2 files. The files have been replaced with sdfs now.
| 0.063076, 0.379931, 0.379931 | ||
| ] * offunit.elementary_charge, | ||
| "library_charges": [ | ||
| # -1 * the ambertools charges should not be possible by anyother method |
There was a problem hiding this comment.
Not sure I understand this comment.
There was a problem hiding this comment.
Tried to clean up the comment let me know if that helps?
| return ET.fromstring(xmldata) | ||
|
|
||
|
|
||
| @pytest.mark.slow |
There was a problem hiding this comment.
The test takes ~1s locally as the charges are no longer generated using ambertools.
| dag_unit.run(dry=True, scratch_basepath=tmp_path, shared_basepath=tmp_path)["debug"]["system"] | ||
|
|
||
|
|
||
| BENZ = """\ |
There was a problem hiding this comment.
They are not used in this file.
IAlibay
left a comment
There was a problem hiding this comment.
A few things (from yesterday and today), overall looks good.
| if errors: | ||
| errmsg = ( | ||
| f"System: '{system.name}' contains SmallMoleculeComponents which may have non-deterministic charges generated at runtime. " | ||
| f"Please provide a molecule with pre-computed charges or use library charges instead. " |
There was a problem hiding this comment.
Should this be ammended to also direct users towards using a deterministic charge method (e.g. AshGC or espaloma)?
There was a problem hiding this comment.
Good point added that to the message.
Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>
Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
Fixes #2115 by adding a validation method that attempts to catch partial charge generation methods which are used at runtime and are nondeterministic.
LLM / AI generated code disclosure
LLMs or other AI-powered tools (beyond simple IDE use cases) were used in this contribution: yes / no
If yes, please provide details here: No
Checklist
newsentry, or the changes are not user-facing.pre-commit.ci autofix.Manual Tests: these are slow so don't need to be run every commit, only before merging and when relevant changes are made (generally at reviewer-discretion).
Developers certificate of origin